lib: Port away from gs_file_rename()
authorColin Walters <walters@verbum.org>
Mon, 1 Aug 2016 01:33:15 +0000 (21:33 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 3 Aug 2016 08:10:27 +0000 (08:10 +0000)
In one case, we already had relative fds and hence this was
nicer.  Unfortunately the other areas got uglier.  More fd-relative
porting to do later.

Closes: #424
Approved by: giuseppe

src/libostree/ostree-bootloader-grub2.c
src/libostree/ostree-sysroot-deploy.c

index 6aa551aea6269f463103813a802263d27ec9f77e..30edb7a560dcf3a255c8ebe60d65bb0c99d19ca4 100644 (file)
@@ -408,9 +408,11 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader      *bootloader,
        */
       if (!ot_gfile_ensure_unlinked (self->config_path_efi, cancellable, error))
         goto out;
-      if (!gs_file_rename (new_config_path, self->config_path_efi,
-                           cancellable, error))
-        goto out;
+      if (rename (gs_file_get_path_cached (new_config_path), gs_file_get_path_cached (self->config_path_efi)) < 0)
+        {
+          glnx_set_error_from_errno (error);
+          goto out;
+        }
     }
   
   ret = TRUE;
index 779c7dc1fe2c816a1d17f5a32b257f289e433188..d4feb7ed5ab0f7f532b1976d6693fbc464fd717d 100644 (file)
@@ -795,9 +795,12 @@ selinux_relabel_var_if_needed (OstreeSysroot                 *sysroot,
                                  cancellable, error))
         goto out;
 
-      if (!gs_file_rename (deployment_var_labeled_tmp, deployment_var_labeled,
-                           cancellable, error))
-        goto out;
+      if (rename (gs_file_get_path_cached (deployment_var_labeled_tmp),
+                  gs_file_get_path_cached (deployment_var_labeled)) < 0)
+        {
+          glnx_set_error_from_errno (error);
+          goto out;
+        }
     }
 
   ret = TRUE;
@@ -861,9 +864,11 @@ merge_configuration (OstreeSysroot         *sysroot,
   else if (etc_exists)
     {
       /* Compatibility hack */
-      if (!gs_file_rename (deployment_etc_path, deployment_usretc_path,
-                           cancellable, error))
-        goto out;
+      if (renameat (deployment_dfd, "etc", deployment_dfd, "usr/etc") < 0)
+        {
+          glnx_set_error_from_errno (error);
+          goto out;
+        }
       usretc_exists = TRUE;
       etc_exists = FALSE;
     }